home *** CD-ROM | disk | FTP | other *** search
/ PC Open 93 / PC Open 93 CD 2.bin / PDF / webdeveloper / lezione_4 / listato 10.txt < prev    next >
Encoding:
Text File  |  2004-01-07  |  2.2 KB  |  90 lines

  1. LISTATO 10 û MODIFICAFOTO_RISPOSTA.ASP
  2.  
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4.  
  5. <html>
  6. <head>
  7.     <title>Gestione foto di Mario Rossi</title>
  8. </head>
  9.  
  10. <body>
  11.  
  12. <h1>Modifica di una foto</h1>
  13.  
  14. <%
  15.  
  16. Const adOpenForwardOnly = 0
  17. Const adLockReadOnly = 1
  18.  
  19. Dim contatore
  20. Dim sql1,sql2
  21. Dim conn, rs
  22. Dim i,j
  23.  
  24. Dim strNome, strTitolo, strData, strLuogo, strProvincia, strStato
  25.  
  26. strNome = request.Form("nome")
  27. strTitolo = request.Form("titolo")
  28. strData = request.Form("datagg") & "/" & request.Form("datamm") & "/" & request.Form("datayyyy")
  29. strLuogo = request.Form("luogo")
  30. strProvincia = request.Form("provincia")
  31. strStato = request.Form("stato")
  32.  
  33. Set conn = Server.CreateObject("ADODB.Connection")
  34. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  35.  
  36. If Not IsDate(strData) Then
  37.     'Data in formato non valido
  38.     response.write "La data inserita (" & strData & ") non Φ valida<br>"
  39.     response.write "Ritorna alla<a href=""gestione.asp"">pagina di gestione</a>"
  40.     response.end
  41. End If
  42.  
  43. 'Rinforzo l'accento per evitare problemi in inserimento
  44. strTitolo = replace(strTitolo,"'","''")
  45. strLuogo = replace(strLuogo,"'","''")
  46.  
  47. sql = "UPDATE Foto SET " & _
  48.     " Foto.Data = '" & strData & "', " & _
  49.     " Foto.Titolo = '" & strTitolo & "'," & _
  50.     " Foto.Luogo = '" & strLuogo & "', " & _
  51.     " Foto.IdProvincia = '" & strProvincia & "', " & _
  52.     " Foto.IdStato = '" & strStato & "'" & _
  53.     " WHERE Foto.Nome = '" & strNome & "'"
  54.  
  55. on error resume next
  56.  
  57. conn.Execute sql
  58.  
  59. If ConnError(conn) > 0 Then
  60.     response.write "Si Φ verificato un problema con la modifica dei dati.<br>"
  61.     response.write "Ritorna alla <a href=""gestione.asp"">pagina di gestione</a>"
  62. Else
  63.     response.write "I dati della foto sono stati modificati correttamente<br>"
  64.     response.write "Ritorna alla <a href=""gestione.asp"">pagina di gestione</a>"
  65. End If
  66.  
  67. on error goto 0
  68.  
  69. set rs = nothing
  70. conn.close
  71. set conn = nothing
  72.  
  73. Function ConnError(conn)
  74.  
  75.   Dim i
  76.   i = 0
  77.  
  78.   For Each errorObject In conn.Errors
  79.       i = i + 1
  80.     Response.Write "ERRORE: " & errorObject.Description & "<br><br>"
  81.   Next
  82.  
  83.   ConnError = i
  84.  
  85. End Function
  86.  
  87. %>
  88.  
  89.  
  90.